import request from '@/utils/request'

// 登录方法
export function login(username, password, code, uuid) {
  const data = {
    username,
    password,
    code,
    uuid
  }
  return request({
    url: '/auth/login',
    headers: {
      isToken: false,
      repeatSubmit: false
    },
    method: 'post',
    data: data
  })
}

// 注册方法
export function register(data) {
  return request({
    url: '/auth/register',
    headers: {
      isToken: false
    },
    method: 'post',
    data: data
  })
}

// 获取用户详细信息
export function getInfo() {
  return request({
    url: '/system/user/getInfo',
    method: 'get'
  })
}

// 退出方法
export function logout() {
  return request({
    url: '/auth/logout',
    method: 'delete'
  })
}

// 获取验证码
export function getCodeImg() {
  return request({
    url: '/code',
    headers: {
      isToken: false
    },
    method: 'get',
    timeout: 20000
  })
}
// 发送短信验证码
export function sendSmsVerifyCode(mobile) {
  return request({
    url: '/auth/sms/sendSmsVerifyCode/'+mobile,
    headers: {
      isToken: false
    },
    method: 'post'
  })
}
// 验证短信验证码
export function smsVerifyCode(mobile,code) {
  return request({
    url: '/auth//sms/verifyCode/'+mobile+'/'+code,
    headers: {
      isToken: false
    },
    method: 'post'
  })
}
// 发送邮件验证码
export function sendMailVerifyCode(mail) {
  return request({
    url: '/auth/mail/sendSmsVerifyCode/'+mail,
    headers: {
      isToken: false
    },
    method: 'post'
  })
}
// 验证邮件验证码
export function mailVerifyCode(mail,code) {
  return request({
    url: '/auth/mail/verifyCode/'+mail+'/'+code,
    headers: {
      isToken: false
    },
    method: 'post'
  })
}
// 混合登录方法
export function loginMixed(data) {
  // const data = {
  //   username,
  //   password,
  //   code,
  //   uuid
  // }
  return request({
    url: '/auth/login',
    headers: {
      isToken: false,
      repeatSubmit: false
    },
    method: 'post',
    data: data
  })
}
//检查手机号唯一性
export function checkPhoneUnique(phone) {
  return request({
    url: '/auth/checkPhoneUnique/'+phone,
    headers: {
      isToken: false
    },
    method: 'post'
  })
}
// 修改密码
export function changePasword(data) {
  // let data = {
  //   mobile:'',
  //   mail:'',
  //   password:''
  // }
  return request({
    url: '/auth/changePasword',
    headers: {
      isToken: false,
      repeatSubmit: false
    },
    method: 'post',
    data: data
  })
}
